<?php
namespace Home\Controller;

class CalendarController extends HomeController {

    public function index(){  
    	$list = M('Event')->order('id desc')->select();
        foreach ($list as $key => $value) {
           $list[$key]['date'] = strtotime("last month",$value['date']);
        }
    	$this->assign('list',$list);  	
    	$this->display();
    }

    public function view(){

    	$id = I('get.id');
        $map['id'] = $id;
    	$list = M('Event')->where($map)->find();
    	if (!$list) {
    		$this->error('The information does not exist');
    	}
        $this->assign('list',$list);
    	$this->assign('userid',$this->userID);
    	$this->display();
    }

    public function save(){
        $eventID = I('post.eventID');
        $email = I('post.email');
        $map['eventID'] = $eventID;
        $map['email'] = $email;
        $list = M("EventOrder")->where($map)->find();
        if ($list) {
            echo $this->echo_json_str('The email address is already exist.',$message,$url);
            die;
        }else{
            $this->all_add('EventOrder');
        }    	
    }
   
}